import React from 'react'
import { Button, Watermark, notification } from 'antd'
import { useNavigate } from 'react-router-dom'
import { api_login } from '@/api/login'
import { setToken } from '@/utils/auth'

export default function Login() {
  const navigate = useNavigate()
  const login = async () => {
    const { data } = await api_login({
      id: '5cf3',
      userName: 'zhagnsna',
      password: '123',
    })
    setToken(data.token)
    notification.success({
      message: '欢迎',
      description: '登录成功',
      duration: 2,
    })

    navigate('/')
  }
  return (
    <Watermark className="h-[100vh]" content="随意的水印">
      <div>
        <Button onClick={login}>登录</Button>
      </div>
    </Watermark>
  )
}
